package com.example.home.rubbish.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.home.R;
import com.example.home.rubbish.bean.NewsClassifyBean;

import java.util.List;

public class NewsHotSeanrchAdapter extends RecyclerView.Adapter<NewsHotSeanrchAdapter.MyHoldy> {
    private Context context;
    private List<NewsClassifyBean.DataBean> list;

    public NewsHotSeanrchAdapter(Context context, List<NewsClassifyBean.DataBean> list) {
        this.context = context;
        this.list = list;
    }

    @NonNull
    @Override
    public MyHoldy onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_search,null);
        return new NewsHotSeanrchAdapter.MyHoldy(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyHoldy holder, int position) {
        holder.keyword.setText(list.get(position).getKeyword());
    }

    @Override
    public int getItemCount() {
        return list == null ? 0 : 12;
    }

    public class MyHoldy extends RecyclerView.ViewHolder {
        private TextView keyword;

        public MyHoldy(@NonNull View itemView) {
            super(itemView);
            keyword = itemView.findViewById(R.id.keyword);
        }
    }
}
